import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';

import '../../../router/route_map.dart';

/// 首页
class HomePage extends StatelessWidget {
  const HomePage({super.key});

  /// 菜单布局
  Widget gridMenuItem(String menuName, GestureTapCallback? onTap) {
    return BrnShadowCard(
      circular: 20,
      child: InkWell(
        onTap: onTap,
        child: Container(
          color: Colors.white,
          padding: const EdgeInsets.all(10),
          child: Text(
            menuName,
            style: const TextStyle(
              fontWeight: FontWeight.bold,
              color: Colors.black,
              fontSize: 20,
            ),
          ),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('核心库演示'),
      ),
      body: GridView.count(
        crossAxisCount: 2,
        scrollDirection: Axis.vertical,
        //宽高比
        childAspectRatio: 3 / 1.2,
        padding: const EdgeInsets.all(12),
        mainAxisSpacing: 12,
        crossAxisSpacing: 12,
        children: [
          gridMenuItem('表格', () {
            RouteMap.pushTableDemo();
          }),
          gridMenuItem('表格-拆分单元格', () {
            RouteMap.pushTableSplitCell();
          }),
          gridMenuItem('图表', () {
            RouteMap.pushChartPage();
          }),
          gridMenuItem('蓝牙', () {
            RouteMap.pushBleDemoState();
          }),
        ],
      ),
    );
  }
}
